﻿using System;
using Character;
using UnityEngine;
using UnityEngine.UI;

// Token: 0x02000427 RID: 1063
[RequireComponent(typeof(Renderer))]
public class SkinMaterialDebug : MonoBehaviour
{
	// Token: 0x06001A47 RID: 6727 RVA: 0x000A8078 File Offset: 0x000A6278
	private void Start()
	{
		this.rend = base.GetComponent<Renderer>();
	}

	// Token: 0x06001A48 RID: 6728 RVA: 0x000A8088 File Offset: 0x000A6288
	private void Update()
	{
		if (Input.GetKeyDown(KeyCode.B))
		{
			this.ChangeMaterial_Body();
		}
		if (Input.GetKeyDown(KeyCode.W))
		{
			this.ChangeMaterial_WearBody();
		}
	}

	// Token: 0x06001A49 RID: 6729 RVA: 0x000A80B0 File Offset: 0x000A62B0
	private void ChangeMaterial_Body()
	{
		Human human = UnityEngine.Object.FindObjectOfType<Human>();
		this.rend.material = human.body.SkinMaterial;
		this.text.text = this.rend.sharedMaterial.name;
	}

	// Token: 0x06001A4A RID: 6730 RVA: 0x000A80F4 File Offset: 0x000A62F4
	private void ChangeMaterial_WearBody()
	{
		Human human = UnityEngine.Object.FindObjectOfType<Human>();
		GameObject obj = human.wears.GetWearObj(WEAR_TYPE.TOP).obj;
		SkinnedMeshRenderer[] componentsInChildren = obj.GetComponentsInChildren<SkinnedMeshRenderer>(true);
		string value = "cf_m_body";
		foreach (SkinnedMeshRenderer skinnedMeshRenderer in componentsInChildren)
		{
			int num = -1;
			for (int j = 0; j < skinnedMeshRenderer.sharedMaterials.Length; j++)
			{
				if (skinnedMeshRenderer.sharedMaterials[j].name.ToLower().IndexOf(value) == 0)
				{
					num = j;
					break;
				}
			}
			if (num != -1)
			{
				this.rend.sharedMaterial = skinnedMeshRenderer.sharedMaterials[num];
				break;
			}
		}
		this.text.text = this.rend.sharedMaterial.name;
	}

	// Token: 0x04001D25 RID: 7461
	private Renderer rend;

	// Token: 0x04001D26 RID: 7462
	[SerializeField]
	private Text text;
}
